package com.junlong0716.enjoylearning.ui

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.view.LayoutInflater
import android.view.View
import com.junlong0716.enjoylearning.MyApp
import com.junlong0716.enjoylearning.R
import com.junlong0716.enjoylearning.adapter.StudyHistoryAdapter
import com.junlong0716.enjoylearning.constant.NetConstant
import com.junlong0716.enjoylearning.net.api.NetApi
import com.lzy.okgo.OkGo
import com.lzy.okgo.callback.StringCallback
import com.lzy.okgo.model.Response
import com.orhanobut.logger.Logger
import kotlinx.android.synthetic.main.activity_study_message.*
import kotlinx.android.synthetic.main.view_title_bar.*
import org.json.JSONObject

class StudyMessageActivity : AppCompatActivity() , View.OnClickListener{
    private lateinit var studyHistoryAdapter: StudyHistoryAdapter
    private lateinit var data: ArrayList<String>

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_study_message)
        initView()
    }

    private fun initView() {
        rl_back.setOnClickListener(this)
        tv_title.text = "文章留言"

        data = ArrayList()

//        studyHistoryAdapter = StudyHistoryAdapter(data, R.layout.item_study_history)
//        rv_message.layoutManager = LinearLayoutManager(this)
//        rv_message.adapter = studyHistoryAdapter
//        studyHistoryAdapter.emptyView = LayoutInflater.from(this).inflate(R.layout.view_empty, null)

        val map = HashMap<String,Int>()
        map["userId"] = MyApp.instance().userAccount!!.id

        OkGo.post<String>(NetConstant.REQUEST_HEADER+NetApi.API_QUERY_MY_COMMENT_KNOWLEDGE)
                .tag(this)
                .upJson(JSONObject(map))
                .execute(object :StringCallback(){
                    override fun onSuccess(response: Response<String>?) {

                    }
                })
    }

    override fun onClick(v: View?) {
        when (v!!.id) {
            R.id.rl_back -> {
                finish()
            }
            else -> {
            }
        }
    }
}
